# Docker for CentOS6.8 Base

# Base image
FROM registry.cn-shenzhen.aliyuncs.com/jc76439984/centos6.8-base:ssh

MAINTAINER "JC <76439984@qq.com>"

# yum源
RUN yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype* && \
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng \
libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc \
glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel \
e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap \
openldap-devel  openldap-clients openldap-servers libxslt-devel libevent-devel ntp  libtool-ltdl \
bison libtool vim-enhanced lynx && yum clean all

# 上传安装包
ADD apache-php/ /tmp/apache-php/

# 安装环境
RUN mkdir -p /home/data/tools
WORKDIR /tmp/apache-php

# 安装apache
RUN tar -xzvf pcre-8.32.tar.gz && cd pcre-8.32 && ./configure --prefix=/home/data/tools/pcre && make && make install
RUN tar -zxf apr-1.4.5.tar.gz && cd apr-1.4.5 && ./configure --prefix=/home/data/tools/apr && make && make install
RUN tar -zxf apr-util-1.3.12.tar.gz && cd apr-util-1.3.12 && ./configure --prefix=/home/data/tools/apr-util --with-apr=/home/data/tools/apr/bin/apr-1-config && make && make install
RUN tar -jxf httpd-2.4.4.tar.bz2 && cd httpd-2.4.4 && ./configure --prefix=/home/data/tools/apache2 \
--enable-so --enable-rewrite --with-pcre=/home/data/tools/pcre/bin/pcre-config \
--with-apr=/home/data/tools/apr --with-apr-util=/home/data/tools/apr-util && \
make && make install && cp /home/data/tools/apache2/bin/apachectl /etc/init.d/httpd

# 安装php
RUN tar -zxv -f php-5.4.12.tar.gz && cd php-5.4.12 && ./configure --prefix=/home/data/tools/php5 \
--with-apxs2=/home/data/tools/apache2/bin/apxs --with-libxml-dir=/usr/local/lib \
--with-zlib-dir=/usr/local/lib --with-mysql --with-mysqli --with-gd --enable-soap \
--enable-sockets  --enable-xml --enable-mbstring --with-png-dir=/usr/local \
--with-jpeg-dir=/usr/local --with-curl=/usr/lib --with-freetype-dir=/usr/include/freetype2/freetype/ \
--enable-bcmath --enable-calendar --enable-zip --enable-maintainer-zts && make && make install

# 清理环境
RUN rm -fr /tmp/apache-php

# 加载配置文件
ADD conf/ /home/data/tools/apache2/conf/
ADD php.ini /home/data/tools/php5/lib/php.ini

# For supervisor
ADD httpd.conf /etc/monit.d/httpd.conf

# EXPOSE
EXPOSE 80 22

CMD ["/usr/bin/monit","-I"]